package com.hita.tata.bbs.account.service;

import com.hita.tata.bbs.account.dao.AccountRepository;
import com.hita.tata.bbs.account.param.request.LoginForm;
import com.hita.tata.bbs.account.param.response.LoginResponse;
import com.hita.tata.common.entity.response.Constant;
import com.hita.tata.common.entity.response.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountService {

	@Autowired
	private AccountRepository accountRepository;

	/**
	 * 检查登录用户是否存在
	 * @param loginForm
	 * @return
	 */
	public ResponseMessage checkLogin(LoginForm loginForm) {
		LoginResponse userInform = accountRepository.checkLogin(loginForm);
		//用户存在
		if(userInform != null) {
			return ResponseMessage.newOkInstance(userInform,Constant.SUCCESS);

		} else {
			//用户不存在
			return ResponseMessage.newErrorInstance(Constant.ERROR);
		}
	}
}
